- Notifications
You must be signed in to change notification settings - Fork 5.8k
/
Copy path2043.Simple Bank System_test.go
62 lines (53 loc) · 1.33 KB
/
2043.Simple Bank System_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package leetcode
import (
"fmt"
"testing"
)
typequestion2043struct {
para2043
ans2043
}
// para 是参数
typepara2043struct {
ops []string
para [][]int64
}
// ans 是答案
typeans2043struct {
ans []bool
}
funcTest_Problem2043(t*testing.T) {
qs:= []question2043{
{
para2043{
[]string{"Bank", "withdraw", "transfer", "deposit", "transfer", "withdraw"},
[][]int64{{10, 100, 20, 50, 30}, {3, 10}, {5, 1, 20}, {5, 20}, {3, 4, 15}, {10, 50}}},
ans2043{[]bool{true, true, true, false, false}},
},
}
fmt.Printf("------------------------Leetcode Problem 2043------------------------\n")
for_, q:=rangeqs {
varbBank
varres []bool
_, p:=q.ans2043, q.para2043
fori, op:=rangep.ops {
ifop=="Bank" {
b=Constructor(q.para[i])
} elseifop=="withdraw" {
isSuccess:=b.Withdraw(int(p.para[i][0]), p.para[i][1])
res=append(res, isSuccess)
} elseifop=="transfer" {
isSuccess:=b.Transfer(int(p.para[i][0]), int(p.para[i][0]), p.para[i][2])
res=append(res, isSuccess)
} elseifop=="deposit" {
isSuccess:=b.Deposit(int(p.para[i][0]), p.para[i][1])
res=append(res, isSuccess)
} else {
fmt.Println("unknown operation")
}
}
fmt.Printf("【input】:%v \n", p)
fmt.Printf("【output】:%v \n", res)
}
fmt.Printf("\n\n\n")
}